package com.novel.service.impl;

import com.novel.mapper.HistoryTagsMapper;
import com.novel.service.HistoryTagsService;
import com.reading.pojo.HistoryTags;
import com.reading.pojo.HistorytagsVo;
import com.reading.pojo.NovelVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;

@Service
public class HistoryTagsServiceImpl implements HistoryTagsService{

    @Autowired
    private HistoryTagsMapper historyTagsMapper;

    @Override
    public List<HistoryTags> findAll(Integer userId) {
        return historyTagsMapper.findAll(userId);
    }

    @Override
    public void deleteAllHistory(Integer userId) {
        historyTagsMapper.deleteAllHistory(userId);
    }

    @Override
    public void saveHistory(HistoryTags historyTags) {
        historyTagsMapper.saveHistory(historyTags);
    }

    @Override
    public HistoryTags findOne(HistorytagsVo historytagsVo) {
        return historyTagsMapper.findOne(historytagsVo);
    }

    @Override
    public void updateTags(HistorytagsVo historytagsVo) {
        historyTagsMapper.updateTags(historytagsVo);
    }

    @Override
    public List<String> findHistoryContent(Integer userId) {
        List<HistoryTags> list = historyTagsMapper.findAll(userId);

        List<String> contentList = list.stream().map(HistoryTags::getContent).collect(Collectors.toList());
        return contentList;
    }
}
